.class public Lcom/glympse/platform/GImage;
.super Ljava/lang/Object;
.source "GImage.java"


# static fields
.field public static final SCALE_EXACT:I = 0x0

.field public static final SCALE_FILL:I = 0x4

.field public static final SCALE_FILL_OR_SMALLER:I = 0x3

.field public static final SCALE_FIT:I = 0x2

.field public static final SCALE_FIT_OR_SMALLER:I = 0x1


# instance fields
.field public m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;


# direct methods
.method public constructor <init>(Landroid/graphics/Bitmap;)V
    .locals 1
    .parameter "oBitmap"

    .prologue
    .line 46
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    .line 48
    new-instance v0, Landroid/graphics/drawable/BitmapDrawable;

    invoke-direct {v0, p1}, Landroid/graphics/drawable/BitmapDrawable;-><init>(Landroid/graphics/Bitmap;)V

    iput-object v0, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    .line 49
    return-void
.end method

.method public constructor <init>(Landroid/graphics/drawable/BitmapDrawable;)V
    .locals 1
    .parameter "oBitmapDrawable"

    .prologue
    .line 40
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    .line 42
    iput-object p1, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    .line 43
    return-void
.end method

.method public constructor <init>(Lcom/glympse/platform/GImage;)V
    .locals 1
    .parameter "oImage"

    .prologue
    .line 32
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    const/4 v0, 0x0

    iput-object v0, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    .line 36
    iget-object v0, p1, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    iput-object v0, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    .line 37
    return-void
.end method

.method public constructor <init>(Ljava/lang/String;ZZ)V
    .locals 4
    .parameter "strPath"
    .parameter "fNoDownsizing"
    .parameter "fNoPurge"

    .prologue
    .line 54
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    const/4 v3, 0x0

    iput-object v3, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    .line 59
    :try_start_0
    new-instance v2, Landroid/graphics/BitmapFactory$Options;

    invoke-direct {v2}, Landroid/graphics/BitmapFactory$Options;-><init>()V

    .line 60
    .local v2, oOptions:Landroid/graphics/BitmapFactory$Options;
    if-nez p2, :cond_0

    .line 62
    const/4 v3, 0x1

    iput-boolean v3, v2, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z

    .line 63
    invoke-static {p1, v2}, Landroid/graphics/BitmapFactory;->decodeFile(Ljava/lang/String;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    .line 65
    invoke-direct {p0, v2, p3}, Lcom/glympse/platform/GImage;->ConfigureBitmapOptions(Landroid/graphics/BitmapFactory$Options;Z)V

    .line 69
    :cond_0
    invoke-static {p1, v2}, Landroid/graphics/BitmapFactory;->decodeFile(Ljava/lang/String;Landroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    move-result-object v1

    .line 70
    .local v1, oBitmap:Landroid/graphics/Bitmap;
    new-instance v3, Landroid/graphics/drawable/BitmapDrawable;

    invoke-direct {v3, v1}, Landroid/graphics/drawable/BitmapDrawable;-><init>(Landroid/graphics/Bitmap;)V

    iput-object v3, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 76
    .end local v1           #oBitmap:Landroid/graphics/Bitmap;
    .end local v2           #oOptions:Landroid/graphics/BitmapFactory$Options;
    :goto_0
    return-void

    .line 72
    :catch_0
    move-exception v3

    move-object v0, v3

    .line 74
    .local v0, e:Ljava/lang/Exception;
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method public constructor <init>([BZZ)V
    .locals 5
    .parameter "abImage"
    .parameter "fNoDownsizing"
    .parameter "fNoPurge"
    .annotation system Ldalvik/annotation/Throws;
        value = {
            Ljava/lang/Exception;
        }
    .end annotation

    .prologue
    .line 81
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 29
    const/4 v3, 0x0

    iput-object v3, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    .line 86
    :try_start_0
    new-instance v2, Landroid/graphics/BitmapFactory$Options;

    invoke-direct {v2}, Landroid/graphics/BitmapFactory$Options;-><init>()V

    .line 87
    .local v2, oOptions:Landroid/graphics/BitmapFactory$Options;
    if-nez p2, :cond_0

    .line 89
    const/4 v3, 0x1

    iput-boolean v3, v2, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z

    .line 90
    const/4 v3, 0x0

    array-length v4, p1

    invoke-static {p1, v3, v4, v2}, Landroid/graphics/BitmapFactory;->decodeByteArray([BIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    .line 92
    invoke-direct {p0, v2, p3}, Lcom/glympse/platform/GImage;->ConfigureBitmapOptions(Landroid/graphics/BitmapFactory$Options;Z)V

    .line 96
    :cond_0
    const/4 v3, 0x0

    array-length v4, p1

    invoke-static {p1, v3, v4, v2}, Landroid/graphics/BitmapFactory;->decodeByteArray([BIILandroid/graphics/BitmapFactory$Options;)Landroid/graphics/Bitmap;

    move-result-object v1

    .line 97
    .local v1, oBitmap:Landroid/graphics/Bitmap;
    new-instance v3, Landroid/graphics/drawable/BitmapDrawable;

    invoke-direct {v3, v1}, Landroid/graphics/drawable/BitmapDrawable;-><init>(Landroid/graphics/Bitmap;)V

    iput-object v3, p0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 103
    .end local v1           #oBitmap:Landroid/graphics/Bitmap;
    .end local v2           #oOptions:Landroid/graphics/BitmapFactory$Options;
    :goto_0
    return-void

    .line 99
    :catch_0
    move-exception v3

    move-object v0, v3

    .line 101
    .local v0, e:Ljava/lang/Exception;
    invoke-static {v0}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/Throwable;)V

    goto :goto_0
.end method

.method private ConfigureBitmapOptions(Landroid/graphics/BitmapFactory$Options;Z)V
    .locals 11
    .parameter "oOptions"
    .parameter "fNoPurge"

    .prologue
    const/4 v10, 0x1

    const/4 v9, 0x0

    .line 110
    iget v5, p1, Landroid/graphics/BitmapFactory$Options;->outWidth:I

    iget v6, p1, Landroid/graphics/BitmapFactory$Options;->outHeight:I

    invoke-static {v5, v6}, Ljava/lang/Math;->min(II)I

    move-result v4

    .line 111
    .local v4, nMin:I
    int-to-double v5, v4

    const-wide/high16 v7, 0x4084

    div-double v0, v5, v7

    .line 114
    .local v0, dDownsample:D
    invoke-static {v0, v1}, Ljava/lang/Math;->floor(D)D

    move-result-wide v5

    double-to-int v2, v5

    .line 115
    .local v2, nDownsample:I
    const/high16 v3, 0x4000

    .line 116
    .local v3, nDownsampleAdjusted:I
    :goto_0
    if-le v3, v10, :cond_0

    and-int v5, v2, v3

    if-eqz v5, :cond_2

    .line 122
    :cond_0
    iput-boolean v9, p1, Landroid/graphics/BitmapFactory$Options;->inJustDecodeBounds:Z

    .line 123
    iput v3, p1, Landroid/graphics/BitmapFactory$Options;->inSampleSize:I

    .line 124
    iput v9, p1, Landroid/graphics/BitmapFactory$Options;->outWidth:I

    .line 125
    iput v9, p1, Landroid/graphics/BitmapFactory$Options;->outHeight:I

    .line 128
    if-nez p2, :cond_1

    .line 130
    :try_start_0
    const-class v5, Landroid/graphics/BitmapFactory$Options;

    const-string v6, "inPurgeable"

    invoke-virtual {v5, v6}, Ljava/lang/Class;->getField(Ljava/lang/String;)Ljava/lang/reflect/Field;

    move-result-object v5

    const/4 v6, 0x1

    invoke-static {v6}, Ljava/lang/Boolean;->valueOf(Z)Ljava/lang/Boolean;

    move-result-object v6

    invoke-virtual {v5, p1, v6}, Ljava/lang/reflect/Field;->set(Ljava/lang/Object;Ljava/lang/Object;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .line 132
    :cond_1
    :goto_1
    return-void

    .line 118
    :cond_2
    shr-int/lit8 v3, v3, 0x1

    goto :goto_0

    .line 130
    :catch_0
    move-exception v5

    goto :goto_1
.end method


# virtual methods
.method public GetScaledBitmap(IIII)Lcom/glympse/platform/GBitmap;
    .locals 18
    .parameter "nWidth"
    .parameter "nHeight"
    .parameter "eScaleType"
    .parameter "nRotation"

    .prologue
    .line 137
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    move-object v5, v0

    if-eqz v5, :cond_0

    if-lez p1, :cond_0

    if-gtz p2, :cond_1

    .line 139
    :cond_0
    const/4 v5, 0x0

    .line 252
    :goto_0
    return-object v5

    .line 142
    :cond_1
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    move-object v5, v0

    invoke-virtual {v5}, Landroid/graphics/drawable/BitmapDrawable;->getIntrinsicWidth()I

    move-result v16

    .line 143
    .local v16, nCurWidth:I
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    move-object v5, v0

    invoke-virtual {v5}, Landroid/graphics/drawable/BitmapDrawable;->getIntrinsicHeight()I

    move-result v15

    .line 148
    .local v15, nCurHeight:I
    if-eqz p3, :cond_3

    move/from16 v0, v16

    move/from16 v1, p1

    if-ne v0, v1, :cond_2

    move v0, v15

    move/from16 v1, p2

    if-eq v0, v1, :cond_3

    .line 156
    :cond_2
    const/4 v5, 0x1

    move v0, v5

    move/from16 v1, p3

    if-ne v0, v1, :cond_4

    move/from16 v0, v16

    move/from16 v1, p1

    if-gt v0, v1, :cond_4

    move v0, v15

    move/from16 v1, p2

    if-gt v0, v1, :cond_4

    .line 159
    move/from16 p1, v16

    .line 160
    move/from16 p2, v15

    .line 221
    :cond_3
    :goto_1
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "Scaling image from "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    move-object v0, v5

    move/from16 v1, v16

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "x"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5, v15}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, " to "

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    move-object v0, v5

    move/from16 v1, p1

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    const-string v6, "x"

    invoke-virtual {v5, v6}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v5

    move-object v0, v5

    move/from16 v1, p2

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/String;)V

    .line 223
    const/4 v4, 0x0

    .line 226
    .local v4, oBitmap:Landroid/graphics/Bitmap;
    move/from16 v0, v16

    move/from16 v1, p1

    if-ne v0, v1, :cond_d

    move v0, v15

    move/from16 v1, p2

    if-ne v0, v1, :cond_d

    .line 228
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    move-object v5, v0

    invoke-virtual {v5}, Landroid/graphics/drawable/BitmapDrawable;->getBitmap()Landroid/graphics/Bitmap;

    move-result-object v4

    .line 236
    :goto_2
    if-nez p4, :cond_e

    .line 238
    new-instance v5, Lcom/glympse/platform/GBitmap;

    invoke-direct {v5, v4}, Lcom/glympse/platform/GBitmap;-><init>(Landroid/graphics/Bitmap;)V

    goto/16 :goto_0

    .line 166
    .end local v4           #oBitmap:Landroid/graphics/Bitmap;
    :cond_4
    const/4 v5, 0x3

    move v0, v5

    move/from16 v1, p3

    if-ne v0, v1, :cond_6

    move/from16 v0, v16

    move/from16 v1, p1

    if-le v0, v1, :cond_5

    move v0, v15

    move/from16 v1, p2

    if-gt v0, v1, :cond_6

    .line 169
    :cond_5
    move/from16 p1, v16

    .line 170
    move/from16 p2, v15

    goto :goto_1

    .line 177
    :cond_6
    const/4 v5, 0x2

    move v0, v5

    move/from16 v1, p3

    if-eq v0, v1, :cond_7

    const/4 v5, 0x1

    move v0, v5

    move/from16 v1, p3

    if-ne v0, v1, :cond_9

    .line 179
    :cond_7
    move/from16 v0, p1

    int-to-double v0, v0

    move-wide v5, v0

    move/from16 v0, v16

    int-to-double v0, v0

    move-wide v7, v0

    div-double v11, v5, v7

    .line 180
    .local v11, dScaleX:D
    move/from16 v0, p2

    int-to-double v0, v0

    move-wide v5, v0

    int-to-double v7, v15

    div-double v13, v5, v7

    .line 184
    .local v13, dScaleY:D
    cmpg-double v5, v11, v13

    if-gtz v5, :cond_8

    .line 186
    int-to-double v5, v15

    mul-double/2addr v5, v11

    move-wide v0, v5

    double-to-int v0, v0

    move/from16 p2, v0

    goto/16 :goto_1

    .line 190
    :cond_8
    move/from16 v0, v16

    int-to-double v0, v0

    move-wide v5, v0

    mul-double/2addr v5, v13

    move-wide v0, v5

    double-to-int v0, v0

    move/from16 p1, v0

    goto/16 :goto_1

    .line 198
    .end local v11           #dScaleX:D
    .end local v13           #dScaleY:D
    :cond_9
    const/4 v5, 0x4

    move v0, v5

    move/from16 v1, p3

    if-eq v0, v1, :cond_a

    const/4 v5, 0x3

    move v0, v5

    move/from16 v1, p3

    if-ne v0, v1, :cond_c

    .line 200
    :cond_a
    move/from16 v0, p1

    int-to-double v0, v0

    move-wide v5, v0

    move/from16 v0, v16

    int-to-double v0, v0

    move-wide v7, v0

    div-double v11, v5, v7

    .line 201
    .restart local v11       #dScaleX:D
    move/from16 v0, p2

    int-to-double v0, v0

    move-wide v5, v0

    int-to-double v7, v15

    div-double v13, v5, v7

    .line 205
    .restart local v13       #dScaleY:D
    cmpl-double v5, v11, v13

    if-ltz v5, :cond_b

    .line 207
    int-to-double v5, v15

    mul-double/2addr v5, v11

    move-wide v0, v5

    double-to-int v0, v0

    move/from16 p2, v0

    goto/16 :goto_1

    .line 211
    :cond_b
    move/from16 v0, v16

    int-to-double v0, v0

    move-wide v5, v0

    mul-double/2addr v5, v13

    move-wide v0, v5

    double-to-int v0, v0

    move/from16 p1, v0

    goto/16 :goto_1

    .line 218
    .end local v11           #dScaleX:D
    .end local v13           #dScaleY:D
    :cond_c
    const/4 v5, 0x0

    goto/16 :goto_0

    .line 232
    .restart local v4       #oBitmap:Landroid/graphics/Bitmap;
    :cond_d
    move-object/from16 v0, p0

    iget-object v0, v0, Lcom/glympse/platform/GImage;->m_oDrawable:Landroid/graphics/drawable/BitmapDrawable;

    move-object v5, v0

    invoke-virtual {v5}, Landroid/graphics/drawable/BitmapDrawable;->getBitmap()Landroid/graphics/Bitmap;

    move-result-object v5

    const/4 v6, 0x1

    move-object v0, v5

    move/from16 v1, p1

    move/from16 v2, p2

    move v3, v6

    invoke-static {v0, v1, v2, v3}, Landroid/graphics/Bitmap;->createScaledBitmap(Landroid/graphics/Bitmap;IIZ)Landroid/graphics/Bitmap;

    move-result-object v4

    goto/16 :goto_2

    .line 241
    :cond_e
    new-instance v5, Ljava/lang/StringBuilder;

    const-string v6, "ROTATING IMAGE BY "

    invoke-direct {v5, v6}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    move-object v0, v5

    move/from16 v1, p4

    invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(I)Ljava/lang/StringBuilder;

    move-result-object v5

    invoke-virtual {v5}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v5

    invoke-static {v5}, Lcom/glympse/platform/common/Helpers;->Log(Ljava/lang/String;)V

    .line 244
    new-instance v9, Landroid/graphics/Matrix;

    invoke-direct {v9}, Landroid/graphics/Matrix;-><init>()V

    .line 245
    .local v9, oMatrix:Landroid/graphics/Matrix;
    move/from16 v0, p4

    int-to-float v0, v0

    move v5, v0

    invoke-virtual {v9, v5}, Landroid/graphics/Matrix;->postRotate(F)Z

    .line 246
    const/4 v5, 0x0

    const/4 v6, 0x0

    const/4 v10, 0x1

    move/from16 v7, p1

    move/from16 v8, p2

    invoke-static/range {v4 .. v10}, Landroid/graphics/Bitmap;->createBitmap(Landroid/graphics/Bitmap;IIIILandroid/graphics/Matrix;Z)Landroid/graphics/Bitmap;

    move-result-object v17

    .line 249
    .local v17, oBitmapRotated:Landroid/graphics/Bitmap;
    invoke-virtual {v4}, Landroid/graphics/Bitmap;->recycle()V

    .line 252
    new-instance v5, Lcom/glympse/platform/GBitmap;

    move-object v0, v5

    move-object/from16 v1, v17

    invoke-direct {v0, v1}, Lcom/glympse/platform/GBitmap;-><init>(Landroid/graphics/Bitmap;)V

    goto/16 :goto_0
.end method
